<?php
class DateFormat {

  	static function format($_date, $format) {
  	
	  	list($date,$time) = explode(" ",$_date);
		list($year,$month,$day) = explode("-",$date);
		list($hours,$mins,$secs) = explode(":",$time);
	  	
		$dmy = $day.".".$month.".".$year;
		$yesterday = date('d.m.Y', mktime(0, 0, 0, date("m") , date("d") - 1, date("Y")));
		$tomorow = date('d.m.Y', mktime(0, 0, 0, date("m") , date("d") + 1, date("Y")));
		
	  	switch($format) {
	  		case DF_DDMMYYYY:
			  	
			  	if(date('d.m.Y') == $dmy) {
			    	return "Dnes";
			  	} else if($yesterday == $dmy) {
			    	return "Včera";
			  	} else if($tomorow == $dmy) {
			  		return "Zítra";
			  	}
			  
			  	return $dmy;
			  	
	  		case DF_DDMM:
	  			
			  	if(date('d.m.Y') == $dmy) {
				    return "Dnes";
				} else if($yesterday == $dmy) {
				    return "Včera";
				} else if($tomorow == $dmy){
				  	return "Zítra";
				}
				
				return $day.".".$month.".";
				
	  		case DF_DDMMYYYYHHMM:
	  			
	  			if(date('d.m.Y') == $dmy) {
					return "Dnes, ".$hours.":".$mins;
				} else if($yesterday == $dmy) {
				    return "Včera, ".$hours.":".$mins;
				} else if($tomorow == $dmy) {
				    return "Zítra, ".$hours.":".$mins;
				}
			  
			  	return $dmy.", ".$hours.":".$mins;
	  	}
	    
	  
	  	
  	}
  
  	static function isDate($date){
		if (ereg('20[0-9][0-9]'.'-'.'[01][1-9]'.'-'.'[0123][1-9]', $date)){
	    	return true;
	  	}
	  	return false;
	}
	
	static function getDay($id_day){
		$days = array("NE", "PO", "ÚT", "ST", "ČT", "PÁ", "SO");
	  	return $days[$id_day - 1];
	}
  
}

?>
